/*
 * @Author: y001554
 * @Date: 2023-01-16 20:11:08
 * @LastEditors: y001554
 * @LastEditTime: 2023-09-03 14:53:28
 * @FilePath: \ylwl\packages\plugins\components\form\src\type.ts
 * @Description:
 *
 * Copyright (c) 2023 by FE/ylwl, All Rights Reserved.
 */
import type { PropType, ExtractPropTypes } from 'vue'
import type { FormItemProps, InputProps } from 'element-plus'
export interface Items {
  label: string
  type: string
  kayName: string
  disabled?: boolean
  fProps?: FormItemProps
  iProps?: any
  options?: Array<OptionObj>
  optionsPromise?: Function
  autoLoadOptions?: boolean
  value?: any
  col?: object
  labelAfter?: Function
  rangeKeys?: string[] //承接的是范围型的列表 扩展字段，该字段值会同步拓展至内部的form表单
  [key: string]: any
}

export interface FooterOptions {
  submitText?: string //  确认文字
  // cancelText?: string //  取消文字
  resetText?: string //  重置文字
  submitShow?: boolean //  确认显示
  // cancelShow?: boolean //  取消显示
  resetShow?: boolean //  重置显示
}

// export interface ToogleOptions {
//   show?: string //
//   cancelText?: string //
// }
export interface CustomerProps {
  // defaultForm?: FormObj //表单默认值
  footerOptions: FooterOptions
  actionShow?: boolean
  // toogleRule?: Array<string> | number
  showLabel?: boolean
  row?: object
  col?: object

  // success?: Function //  确认函数
  // cancel?: boolean //  取消函数
  // reset?: boolean //  重置函数
}

export interface FormObj {
  [key: string]: any
}

export interface OptionObj {
  value: string | number
  label: string
}

export type ItemData = Array<Items>
// export type TypeModelValue = Array<string | number>

export const componentProps = {
  formModel: {
    type: Array as PropType<ItemData>,
    default: () => []
  },

  customerProps: {
    type: Object as PropType<CustomerProps>,
    default: () => ({})
  },
  modelValue: {
    type: Object,
    default: () => ({})
  },
  inline: {
    type: Boolean,
    default: false
  }
} as const

export type ComponentProps = ExtractPropTypes<typeof componentProps>
